<template>
  <div>
    <div class="row1">
      <div class="top">
        <div class="search">
          <el-input v-model="input" placeholder="搜索你想要的内容" style="width: 300px;"></el-input>
          <el-button type="warning" round @click="onSubmit()">搜索</el-button>
        </div>
        <div class="pic2">
          <div>
            <div class="pic21">
              <img
                src="http://qoz3190o1.hd-bkt.clouddn.com/src%3Dhttp___bpic.588ku.com_element_origin_min_pic_00_91_84_2256f1844a88731.jpg%26refer%3Dhttp___bpic.588ku.jpg"/>
              <div class="pic22">上传视频</div>
            </div>
          </div>
          <div>
            <div class="pic21">
              <img src="http://qoz3190o1.hd-bkt.clouddn.com/u%3D1091995538%2C4097802728%26fm%3D26%26gp%3D0.jpg"/>
              <div class="pic22">充值抖币</div>
            </div>
          </div>
          <div>
            <div class="pic21" @mouseover="showpic()" @mouseleave="showpic2()">
              <img src="http://qoz3190o1.hd-bkt.clouddn.com/u%3D1416799284%2C860429581%26fm%3D26%26gp%3D0.jpg"/>
              <div class="pic22">用户</div>
              <div class="pic22"></div>
            </div>
          </div>
        </div>
        <div class="row11">
          同城
        </div>
      </div>
    </div>
    <div class="under">
      <div class="city">
        <i style="font-size: xx-large" class="el-icon-location-information" @click="getaddress()"></i>
        <span>{{address}}</span>
      </div>
      <div class="row52">
        <span v-for="(iteam,index) in videoList" class="row521">
              <div class="row52111">
                <video controls class="vjs-custom-skin">
                  <source type="video/mp4"
                          :src="iteam.videoUrl"/>
                </video>
                <div  @click="videoplay(iteam.videoId)" class="row52112">
                   <el-avatar :src="iteam.userPic"></el-avatar>
                  <span >{{iteam.videoInfo}}</span>
                </div>
              </div>
            </span>
      </div>
    </div>
  </div>
</template>

<script>

  import axios from 'axios';

  export default {
    name: "samecity",
    data() {
      return {
        address: '',
        input: '',
        videoList: [],
      }
    },
    methods: {
      getLocation() {
        let _this = this;
        let geolocation = new BMap.Geolocation();  // 创建百度地理位置实例，代替 navigator.geolocation
        geolocation.getCurrentPosition(function (e) {
          if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            // 百度 geolocation 的经纬度属性不同，此处是 point.lat 而不是 coords.latitude
            // console.log(_this.lng, _this.lat);
            let point = new BMap.Point(e.point.lng, e.point.lat);
            let gc = new BMap.Geocoder();
            gc.getLocation(point, function (rs) {
              let addComp = rs.addressComponents;  // 返回的结果，大家可以先把rs打印出来看看是什么
              let address = addComp.city + addComp.district + addComp.street;  // 拼接地址
              _this.address = address;
              window.sessionStorage.setItem('address', address);  // 地址存入sessionStorage，再次进入页面就不需要再次请求位置了
            });
          } else {
            console.log(this.getStatus());
          }
        });
      },
      getaddress() {
        let _this = this;
        let sessionLocal = window.sessionStorage.getItem('address');
        if (sessionLocal) {
          _this.address = sessionLocal.slice(0, 2);
        } else {
          _this.getLocation();
        }
        axios.post("http://localhost/kd-user/user/findbycity", {userAddress: this.address}).then(res => {
          if (res.data.code === 200) {
            this.videoList = res.data.data;
          }
        })
      },
      videoplay(videoId){
        this.$cookie.set("videoId",videoId);
        this.$router.push("/videoplay");
      },
    },
    mounted() {
      this.getaddress();
    }
  }
</script>

<style scoped>
  .search {
    width: 500px;
    height: 50px;
    margin: auto;
  }

  .pic1 img {
    width: 100%;
    height: 390px;
    float: left;
  }

  .top {
    width: 100%;
    height: 130px;
    background: bisque;
  }

  .pic2 {
    position: absolute;
    top: 10px;
    right: 30px;
    width: 270px;
    height: 90px;
    float: left;
  }

  .pic21 {
    width: 90px;
    height: 90px;
    float: left;
  }

  .pic2 img {
    width: 35px;
    height: 35px;
  }

  .pic22 {
    width: 90px;
    height: 30px;
    float: left;
    color: aqua;
  }

  .row52 {
    width: 97%;
    height: auto;
    margin-left: 50px
  }

  .row711 img {
    width: 100px;
    height: 100px;
    margin-top: 25px;
    border-radius: 50px;
  }

  .row521{
    width: 300px;
    height: 600px;
    float: left;
  }

  .row52111 {
    width: 180px;
    height: 300px;
    margin: auto;
  }

  .vjs-custom-skin {
    width: 280px;
    height: 500px;
  }

  .row52112 {
    width: 280px;
    height: 60px;
    text-align: initial;
    cursor: pointer;
  }

  .row521121 {
    width: 50px;
    float: right;
    height: 30px;
    line-height: 30px;
    color: chocolate;
  }

  .row521122 {
    width: 70px;
    float: right;
    height: 30px;
    line-height: 30px;
    color: chocolate;
  }

  .under {
    width: 100%;
    height: auto;
  }

  .city{
    margin: auto;
    width: 1400px;
    height: 40px;
    line-height: 40px;
    background-color: rgb(224,205,207);
    border-radius: 10px;

  }

  .row11 {
    height: 50px;
    width: 230px;
    font-size: xx-large;
    text-align: right;
    font-weight: bolder;
    font-style: italic;
    color: coral;
  }

  ::-webkit-scrollbar{
    /*垂直滚动条的宽*/
    width: 5px;
    height: 16px;
  }
  ::-webkit-scrollbar-track-piece{
    /*修改滚动条的背景和圆角*/
    background: #abcdef;
    -webkit-border-radius: 6px;
  }
  /*修改垂直滚动条的样式*/
  ::-webkit-scrollbar-thumb:vertical{
    background-color: #ffffff;
    -webkit-border-radius: 6px;
  }

  /*修改水平滚动条的样式*/
  ::-webkit-scrollbar-thumb:horizontal{
    background-color: #faa;
    -webkit-border-radius: 6px;
  }

</style>
